package zerdlib.swing.model;

import javax.swing.ComboBoxModel;
import zerdlib.events.containers.ListenableCollection;


public class ComboBoxModelWrapper<E> extends ListModelWrapper<E> implements ComboBoxModel<E> {
	private static final long serialVersionUID = -7851892216193303052L;
	
	private Object selectedObject = null;
	

	public ComboBoxModelWrapper(ListenableCollection<E> collection) {
		super(collection);
	}
	
	@Override
	public void setSelectedItem(Object anItem) {
		if ((selectedObject != null && !selectedObject.equals( anItem )) ||
				selectedObject == null && anItem != null) {
			selectedObject = anItem;
			fireContentsChanged(this, -1, -1);
		}
	}

	@Override
	public Object getSelectedItem() {
		return selectedObject;
	}

}
